using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace LightPersist.Storage
{
	public static class CloneUtils
	{
		static bool HelpClone<T>(out T res, object obj) where T : class
		{
			return (res = obj as T) != null;
		}

		public static object CloneIfList(object obj)
		{
			List<Reference> r1;
			if (HelpClone(out r1, obj)) return new List<Reference>(r1);

			List<BackReference> r2;
			if (HelpClone(out r2, obj)) return new List<BackReference>(r2);

			return obj;
		}


	}
}